<?php
namespace app\base\model;
use think\Session;
use think\Validate;
use think\Db;
class CityM extends Base
{

       protected function _V($scene,$data)
       {
           $rule = [
               'id' => 'require|number',
           ];
        $msg = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID只能是数字',
        ];
           $validate = new Validate($rule,$msg);
           $validate->scene('add', ['id']);
           $result = $validate->scene($scene)->check($data);
           if($result === false)
           {
               return $validate->getError();
           }
           else
           {
               return true;
           }

       }

    /**
     * 城市级别
     * @param int $level
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function getCityByLevel($level=0)
    {
        return Db::table('city')->where('level',$level)->select();
    }
}
